'''
Copyright(C),2021-2031, Zhenxin Tech. Co., Ltd.

FilePath: server.py
Author: zhangys
Date: 1969-12-31 16:00:00
LastEditTime: 2021-12-14 19:08:07
LastEditors: zhangys
Description: 服务端
'''
from example_interfaces.srv import AddTwoInts
import rclpy
from rclpy import service
from rclpy.node import Node

class Service(Node):
    def __init__(self):
        super().__init__('zys_service')
        self.srv=self.create_service(AddTwoInts,'zys_add',self.addCallBack)
    
    def addCallBack(self,request,response):
        response.sum=request.a+request.b
        self.get_logger().info('输入的值为\n a:：%d b:%d' %(request.a,request.b))
        return response

def main(args=None):
    rclpy.init(args=args)
    zys_service=Service()
    rclpy.spin(zys_service)
    rclpy.shutdown()

if __name__ == '__main__':
    main()
